<?php
class ArticleModel extends Model {
	var $tableName = 'cms_article';
	/**
	 * 根据栏目ID获取内容列表
	 * M2
	 */
	public function getArticleList($id) {
		if(!empty($id)) {
			if(($res = S('articlelist_'.$id)) === false) {
				$data['cid'] = intval($id);
				$data['status'] = 1;
				$list = $this->where($data)->order('display_order asc,id asc')->select();
				$arr = array ();
				foreach ( $list as $key => $value ) {
					$arr [] = array (
							'id' => $value['id'],
							'pId' => 0,
							'name' => $value ['title'],
							'open' => true
					);
				}
				S('articlelist_'.$id,$arr);
				return json_encode($arr);
			} else {
				return json_encode($res);
			}
		}
	}
	
	public function getCountContents($cateid) {
		$data['cid'] = intval($cateid);
		$count = $this->where($data)->count(1);
		return $count;
	}
}

?>